From be13a23722b6308b0e381163bb3f9f6d7e031290 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 15 Oct 2019 19:05:52 -0400 Subject: [PATCH] icon theme: Avoid mime sniffing Themed icons are always pngs or svgs. Take advantage of that to avoid costly mime sniffing. --- gtk/gtkicontheme.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 8a580fb4ac..ee7f7c49bb 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -3384,16 +3384,19 @@ icon_info_ensure_scale_and_texture (GtkIconInfo *icon_info) &icon_info->load_error); else if (size == 0) source_pixbuf = _gdk_pixbuf_new_from_resource_scaled (icon_info->filename, + "svg", icon_info->desired_scale, &icon_info->load_error); else - source_pixbuf = gdk_pixbuf_new_from_resource_at_scale (icon_info->filename, - size, size, TRUE, - &icon_info->load_error); + source_pixbuf = _gdk_pixbuf_new_from_resource_at_scale (icon_info->filename, + "svg", + size, size, TRUE, + &icon_info->load_error); } else - source_pixbuf = gdk_pixbuf_new_from_resource (icon_info->filename, - &icon_info->load_error); + source_pixbuf = _gdk_pixbuf_new_from_resource (icon_info->filename, + "png", + &icon_info->load_error); } else { @@ -3425,19 +3428,22 @@ icon_info_ensure_scale_and_texture (GtkIconInfo *icon_info) &icon_info->load_error); else if (size == 0) source_pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, + "svg", icon_info->desired_scale, NULL, &icon_info->load_error); else - source_pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, - size, size, - TRUE, NULL, + source_pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream, + "svg", + size, size, + TRUE, NULL, &icon_info->load_error); } else - source_pixbuf = gdk_pixbuf_new_from_stream (stream, - NULL, - &icon_info->load_error); + source_pixbuf = _gdk_pixbuf_new_from_stream (stream, + "png", + NULL, + &icon_info->load_error); g_object_unref (stream); } } @@ -3938,7 +3944,8 @@ gtk_icon_info_load_symbolic_svg (GtkIconInfo *icon_info, g_free (height); stream = g_memory_input_stream_new_from_data (data, -1, g_free); - pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, + pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream, + "svg", gdk_texture_get_width (icon_info->texture), gdk_texture_get_height (icon_info->texture), TRUE, -- 2.30.2